﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using Engine.Objects;
namespace NOWAOnline.Scenes.LoginScene
{
    class LoginScene3d:DrawableGameComponent, Engine.Interface.IEngineObject
    {
        string _name;
        BasicEffect eff;
        public string Name
        {
            get
            {
               return _name;
            }
            set
            {
               _name=value;
            }
        }

        public LoginScene3d(Engine.NOWAEngine _game):base(_game)
        {
            _name = "3dScene";
        }
        public bool isGUI
        {
            get { return false; }
        }
        public override void Draw(GameTime gameTime)
        {
            DepthStencilState s = new DepthStencilState();
            s.DepthBufferEnable = true;
            Game.GraphicsDevice.DepthStencilState = s;
            RasterizerState r = new RasterizerState();
            r.CullMode = CullMode.None;
            Game.GraphicsDevice.RasterizerState = r;

            DEFAULTCamera cam = (DEFAULTCamera)(((Engine.NOWAEngine)Game).Manager.GetComponent("CameraManager")).GetMaincamera();

            eff.View = cam.ViewMatrix;
            eff.Projection = cam.ProjectionMatrix;
            eff.World = Matrix.Identity;
            eff.VertexColorEnabled = true;
            VertexPositionColor[] ver = new VertexPositionColor[6];
            ver[0] = new VertexPositionColor(new Vector3(0, 0, 0), Color.Black);
            ver[1] = new VertexPositionColor(new Vector3(1, 0, 0), Color.Violet);
            ver[2] = new VertexPositionColor(new Vector3(0, 1, 0), Color.Wheat);
            ver[3] = new VertexPositionColor(new Vector3(0, 0, 0), Color.Black);
            ver[5] = new VertexPositionColor(new Vector3(1, 0, 0), Color.Violet);
            ver[4] = new VertexPositionColor(new Vector3(0, 1, 0), Color.Wheat);
            //ver[0] = new VertexPositionColor(new Vector3(1, 0, 10), Color.Violet);

            foreach (EffectPass pass in eff.Techniques[0].Passes)
            {
                pass.Apply();
                GraphicsDevice.DrawUserPrimitives<VertexPositionColor>(PrimitiveType.TriangleList, ver, 0, 2);
            }
                base.Draw(gameTime);
        }    
        public new void LoadContent()
        {
            eff = new BasicEffect(Game.GraphicsDevice);
            
        }


        public Vector3 Position
        {
            get
            {
                throw new NotImplementedException();
            }
            set
            {
                throw new NotImplementedException();
            }
        }

        public Quaternion Rotation
        {
            get
            {
                throw new NotImplementedException();
            }
            set
            {
                throw new NotImplementedException();
            }
        }

        public Matrix Transform
        {
            get
            {
                throw new NotImplementedException();
            }
            set
            {
                throw new NotImplementedException();
            }
        }

        public Vector3 Scale
        {
            get
            {
                throw new NotImplementedException();
            }
            set
            {
                throw new NotImplementedException();
            }
        }
    }
}
